package sortForeign;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class sortCityForeignBean implements WritableComparable<sortCityForeignBean> {
    private float foreign_marriages;

    public sortCityForeignBean(){

    }

    public sortCityForeignBean(float foreign_marriages){
        this.foreign_marriages = foreign_marriages;
    }

    public void set(float foreign_marriages){
        this.foreign_marriages = foreign_marriages;
    }

    public float getForeign_marriages() {
        return foreign_marriages;
    }

    public void setForeign_marriages(float foreign_marriages) {
        this.foreign_marriages = foreign_marriages;
    }

    @Override
    public String toString() {
        return "\t" + foreign_marriages;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeFloat(foreign_marriages);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.foreign_marriages = dataInput.readFloat();
    }

    @Override
    public int compareTo(sortCityForeignBean o) {
        return this.foreign_marriages - o.getForeign_marriages() > 0 ? -1 : (this.foreign_marriages - o.getForeign_marriages() < 0 ? 1 : 0) ;
    }
}
